import { StringHelper } from "../../../com/gengine/utils/StringHelper";
import { ConfigManager } from "../../../com/gengine/resource/ConfigManager";
type int = number;
//class DailyConfig
    
    export  class DailyConfig
    {
        constructor()
        {
            
            this._map = new Map<any, any> /* flash.utils.Dictionary */();
            this._mapArr = [];
            this._activeMap = new Map<any, any> /* flash.utils.Dictionary */();
            if (DailyConfig._instance != null) 
            {
                throw new Error(" DailyConfig 单例 ");
            }
            this.init();
            return;
        }

        /* internal  */write(arg1: Object): void
        {
            var loc1=null;
            this._mapArr.splice(0);
            var loc2=0;
            var loc3=arg1;
            for(loc1 of loc3) 
            {
                this._list = StringHelper.getString(loc1.active).split("#");
                this._list.sort(this.listSortFun);
                this._map[int(loc1.id)] = this._list;
                this._mapArr.push(loc1);
            }
            this._mapArr.sort(this.mapArrSortFun);
            return;
        }

        /* internal  */writeActive(arg1: Object): void
        {
            var loc1=null;
            var loc2=0;
            var loc3=arg1;
            for(loc1 of loc3) 
            {
                this._activeMap[loc1.type] = loc1;
            }
            return;
        }

        /* internal  */listSortFun(arg1: string, arg2: string): int
        {
            var loc1=this._list.indexOf(arg1);
            var loc2=this._list.indexOf(arg2);
            if (loc1 <= loc2) 
            {
                return -1;
            }
            return 1;
        }

        /* internal  */mapArrSortFun(arg1: Object, arg2: Object): int
        {
            if (int(arg1.id) < int(arg2.id)) 
            {
                return -1;
            }
            return 1;
        }

        public init(): void
        {
            var loc1=ConfigManager.instance.getJSONByFileName("t_daily.json");
            this.write(loc1);
            loc1 = ConfigManager.instance.getJSONByFileName("t_acitve_specail_config.json");
            this.writeActive(loc1);
            return;
        }

        public getInfoByType(arg1: int): Array<any>
        {
            return this._map[arg1] as Array<any>;
        }

        public getInfoAsTabBarProvider(): Array<any>
        {
            var loc1=0;
            var loc3=null;
            var loc5=null;
            var loc2=this._mapArr.length;
            var loc4=[];
            while (loc1 < loc2) 
            {
                loc3 = this._mapArr[loc1];
                if (int(loc3.id) == 0 || int(loc3.id) == 6) 
                {
                    ++loc1;
                    continue;
                }
                loc5 = {"label": loc3.name + "", "name":"item" + loc3.id, "id": loc3.id, "img":"dailyTab_" + loc3.id + ".png"};
                loc4.push(loc5);
                ++loc1;
            }
            loc5 = loc4.pop();
            loc4.unshift(loc5);
            return loc4;
        }

        public specailRewardGetRule(arg1: int): int
        {
            var loc1=null;
            if (this._activeMap.hasOwnProperty(arg1)) 
            {
                loc1 = this._activeMap[arg1];
                if (loc1) 
                {
                    return int(loc1.rewardByMail);
                }
            }
            return 0;
        }

        public static get instance(): DailyConfig
        {
            if (DailyConfig._instance == null) 
            {
                DailyConfig._instance = new DailyConfig();
            }
            return DailyConfig._instance;
        }

        /* internal */ /* var */_map: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ /* var */_mapArr: Array<any>;

        /* internal */ /* var */_activeMap: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ /* var */_list: Array<any>;

        /* internal */ static /* var */_instance: DailyConfig;
    }
